IOCTL Statement Example The following example shows how to communicate with a device driver using a hypothetical device driver named ENGINE. The IOCTL statement sets the data mode in the driver and the IOCTL$ function tests the data mode. OPEN "\DEV\ENGINE" FOR OUTPUT AS #1 IOCTL #1, "RAW"' Tells the device that the data is raw. ' If the character driver "ENGINE" responds "false" from the raw data ' mode in the IOCTL statement, then the file is closed. IF IOCTL$(1) = "0" THEN CLOSE 1 IOCTL Statement ---------------------------------------------------------------------------- Action Transmits a control data string to a device driver. Syntax IOCTL # filenumber%, string$ Remarks The IOCTL statement uses the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- filenumber% The BASIC file number used to open the device. string$ The command sent to the device. Commands are specific to the device driver. See the documentation for the device driver for a description of the valid IOCTL commands. An IOCTL control data string can be up to 32,767 bytes long. The IOCTL statement works only if all of the following conditions are met. - The device driver is installed. - The device driver states that it processes IOCTL strings. See the documentation for the driver. You also can test for IOCTL support through DOS function &H44 by using interrupt &H21 and the INTERRUPT routine. For more information about interrupt &H21, function &H44, see see the Microsoft MS-DOS Programmer's Reference, or books such as Advanced MS-DOS or The Peter Norton Guide to the IBM PC. - BASIC performed an OPEN operation on a file on that device, and the file is still open. Most standard DOS device drivers do not process IOCTL strings, and you must determine whether the specific driver accepts the command. If the driver does not process IOCTL strings, BASIC generates the error message Illegal function call. Note BASIC devices (LPT n, COM n, SCRN, CONS, PIPE) and DOS block devices (A through Z) do not support IOCTL. The IOCTL statement is not available in OS-2 protected mode. However, you can achieve the same effect by directly invoking the DosDevIOCtl OS-2 function. See Also IOCTL$ Function Example See the IOCTL$ function programming example, which shows how the IOCTL statement and the IOCTL$ function are used with a device driver.